home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_09 / barbu / descript.hpp < prev    next >
C/C++ Source or Header  |  1996-06-18  |  1KB  |  51 lines

  1. Listing3
  2.  
  3. /////////////////////////////////////////////////////
  4. // DESCRIPT, a STR-ing used as a descriptor:
  5. //  <type>['|'<param>=<value>]
  6. /////////////////////////////////////////////////////
  7. #if !defined(DESCRIPT_HPP)
  8. #define DESCRIPT_HPP
  9. #if !defined(RC_INVOKED)    // real C++ stuff
  10. #include "STR.HPP"
  11. class DESCRIPT : public STR {
  12. public:
  13.     DESCRIPT(const char szS[] = 0);
  14.     virtual ~DESCRIPT();
  15.  
  16.     const char* type(STR& Buf) const;
  17.     const char* value(const char szParam[], STR& Buf)
  18.                                 const;
  19.     int value(const char szParam[], int nDefVal = 0)
  20.                                 const;
  21.  
  22.     void setType(const char szType[]);
  23.     void addParam(const char szParam[],
  24.                     const char szValue[]);
  25.     void addParam(const char szParam[], int nValue);
  26.  
  27. private:
  28.     short isSep(int c, int k) const;
  29.     const char* retVal(STR& Buf) const;
  30.     enum { SLASH = '|', EQUAL = '=' , LIT = '\\'};
  31. };
  32.  
  33. class MULTIPARAM {
  34. public:
  35.     MULTIPARAM(const DESCRIPT* Desc,
  36.                 const char szMP[]);
  37.     ~MULTIPARAM() {};
  38.     int no() const { return _n; }
  39.     const char* value(int index, STR& Buf);
  40.     int value(int index, int nDefVal = 0);
  41.  
  42. private:
  43.     const DESCRIPT* const _desc;
  44.     const STR _mp;
  45.     int _n;
  46.     STR _full;
  47.     const char *_makeParam(int index);
  48.     };
  49. #endif
  50. #endif
  51.